Newer
Older
Digital_Repository / Repositories / Maps / Otago Eprints / Eclipse_Projects / Setup / Setup_Tests / GEOIP_Test.pl
#!/usr/bin/perl

use Geo::IP;
my ($gi);
my ($gidb) = "/usr/local/share/GeoIP/GeoLiteCity.dat";
my ( $ip,  $count, $record );
my ( $lat, $long,  $city, $key, $country ) = ( 0, 0, '', '', '' );

$gi = Geo::IP->open( $gidb, GEOIP_STANDARD )
  or die "Unable to open GeoIP database $gidb\n";
$record = $gi->record_by_addr('201.78.239.59');

print $record->country_code."\n".
        $record->country_code3."\n".
        $record->country_name."\n".
        $record->region."\n".
        $record->city."\n".
        $record->latitude."\n".
        $record->longitude;